<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <!-- コンテナをロード -->
  <script type="text/javascript" src="../src/container.js" ></script>
</head>
<body>
  <div id="stdout"></div>
  <script type="text/javascript">
var stdout = document.getElementById( "stdout" );

// クラス
function Kitten() {}
Kitten.prototype = {
   run:function() { stdout.innerHTML += this.name + " : teku teku" + "<br/>"; },
   meow:function() { stdout.innerHTML += this.name + " : meow" + "<br/>"; }
};

function Tiger() {}
Tiger.prototype = {
   run:function() { stdout.innerHTML += this.name + " : teku teku" + "<br/>"; },
   bite:function() { stdout.innerHTML += this.name + " : gabu" + "<br/>"; }
};

var kitten = new Kitten();
var tiger  = new Tiger();

function check( title, type ) {
    stdout.innerHTML += "--- " + title + "<br/>";
    stdout.innerHTML += type.isImplementor(kitten) + "<br/>";
    stdout.innerHTML += type.isImplementor(tiger) + "<br/><br/>";
}


//「指定したAPIをすべて持つ」条件
// 引数として、文字列, 正規表現またはcontainer.Typeが指定できる。
var type = container.types.has( "run", /bit.*/ );
check( "container.types.has( 'run', /bit.*/ )", type );

// 「いずれかのAPIを持つ」条件
type = container.types.hasAny( "bite", /meo.*/ );
check( "container.types.hasAny( 'bite', /meo.*/ )", type );

// 条件の否定
type = container.types.not( container.types.has( "bite" ) );
check( "container.types.not( container.types.has( 'bite' ) )", type );

// 条件のネスト
type = container.types.hasAny(
  container.types.has( "bite", "run" ),
  container.types.not(
    container.types.hasAny( "meow" )
  )
);
check( "nested.", type );

  </script>
</body>
</html>